<?php
if($_GET['mode']=="edit"){
   if($_POST['submit_poll']!=true) echo '';
   else {
      $poll_name = addslashes(trim(htmlspecialchars($_POST['poll_name'])));
	  $poll_descr = addslashes(trim(htmlspecialchars($_POST['poll_descr'])));;
	  
	  if(empty($poll_name) || empty($poll_descr)){
	     echo '<p class="error">Моля, попълнете ВСИЧКИ полета!</p>';
	  } else {
	     $sel_m = mysql_query('SELECT vapros FROM poll_vaprosi WHERE vapros = "'.$tut_name.'" AND v_id != '.$_GET['id'].'');
		 if(mysql_num_rows($sel_m) != 0){
		    echo '<p class="error">Името на анкетата е заето!</p>';
		 } else {
		    if(strlen($poll_name)<3 || strlen($poll_descr)<3){
			   echo '<p class="error">Кратко име и/или описание и/или анкета</p>';
			} else {
			   $update='UPDATE poll_vaprosi SET vapros="' . $poll_name. '", descr="'. $poll_descr . '" WHERE v_id='.$_GET['id'].'';
		       $res_update=mysql_query($update);
			   echo '<p class="success">Успешно обновяване!</p>';
			   echo '<meta http-equiv="refresh" content="1;url=editpoll.php">';
			} 
		 }
	  }
   }
}
?>